<?php

namespace App\Console\Commands;

use App\depository\ManageForbiddenDep;
use Illuminate\Console\Command;
use GuzzleHttp\Client;

class ForbiddenExpCmd extends Command{

    public $signature = 'forbidden:exp';

    public function handle()
    {
        $dep = new ManageForbiddenDep();

        $resAll = $dep->getByStatus([ManageForbiddenDep::STATUS_ONE,ManageForbiddenDep::STATUS_THREE]);

        if($resAll->isEmpty()){
            $this->info('have no task');
            return false;
        }

        $resAll->each(function($item) use ($dep){
           $endAt = $item->end_time;
           $current = date('Y-m-d H:i:s');
           if($endAt <= $current){
               $this->info("deal {$item->id} {$endAt} {$current}");
               $dep->update($item->id,['status'=> ManageForbiddenDep::STATUS_SIX]);
           }
        });
        $this->info("deal over");
    }

}


